stage.set_axis(8)
stage.create_grid_overlay(1, "black")
x_label = codesters.Text("x", 7.5, -.5)
x_label.set_size(.8)
y_label = codesters.Text("y", .3, 7.5)
y_label.set_size(.8)
def arrow(axis, scale, color):
if axis == "x":
top1 = codesters.Line(scale, 0, scale - .3, .5, color)
bottom1 = codesters.Line(scale, 0, scale - .3, -.5, color)
top2 = codesters.Line(-scale, 0, -scale + .3, .5, color)
bottom2 = codesters.Line(-scale, 0, -scale + .3, -.5, color)
if axis == "y":
top1 = codesters.Line(0, scale, .5, scale -.3, color)
bottom1 = codesters.Line(0, scale, -.5, scale-.3, color)
top2 = codesters.Line(0, -scale, .5, -scale +.3, color)
bottom2 = codesters.Line(0, -scale, -.5 , -scale + .3, color)
arrow("x", 8, "black")
arrow("y", 8, "black")
goal_sprite = codesters.Point(5, -2)
goal_sprite.set_color("green")
goal_sprite.say("\n\nI'm the goal!")
sprite = codesters.Point(0, 0)
sprite.set_color("blue")
sprite.pen_down()
sprite.go_to(-2, 5)
try:
tval1 = sprite.get_x()
tval2 = sprite.get_y()
except:
tval1 = "DNE"
tval2 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == 5 and tval2 == -2, "Great job debugging the program!")
t1.add_failure(tval1 == "DNE" or tval2 == "DNE", "Oops! Did you delete your sprite?")
t1.add_failure(tval1 == 0 and tval2 == 0, "Oops! Did you delete the Glide To command?")
t1.add_failure(tval1 != 5 or tval2 != -2, "Make sure you fix the Glide To command so your sprite goes to (5, -2)!")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()